-
Notifications
You must be signed in to change notification settings - Fork 123
Extract query ID from all kill_query procedure variations #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract query ID from all kill_query procedure variations #425
Conversation
0f19b85 to
1ad0e45
Compare
mosabua
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine .. I wish we would not have to mock around for stuff like that but a full integration test seems worse..
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
1ad0e45 to
a8355b6
Compare
a8355b6 to
83760bd
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
9a00f3e to
95e782a
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
ebyhr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regular expression is incorrect in some cases.
95e782a to
c311199
Compare
|
Needs a rebase now.. |
c311199 to
e9226b6
Compare
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
805fd81 to
e805660
Compare
|
@ebyhr I switched to using the full query parser, which should be resilient to whitespace, comments, the string literals containing the procedure name, etc |
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
e805660 to
6e9842a
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
6e9842a to
76f2c68
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/config/RequestAnalyzerConfig.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
76f2c68 to
f4ee990
Compare
cb54a46 to
b8ed756
Compare
ebyhr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash the 3rd commit into the 1st commit.
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableCallArgument.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
2e2cc3e to
25359b1
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
| this.schemas = requireNonNullElse(schemas, ImmutableSet.of()); | ||
| this.catalogSchemas = requireNonNullElse(catalogSchemas, ImmutableSet.of()); | ||
| this.isNewQuerySubmission = isNewQuerySubmission; | ||
| this.procedureArguments = requireNonNullElse(procedureArguments, ImmutableList.of()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does procedureArguments become null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
procedureArguments will be null if TrinoQueryProperties is constructed from a json that does not include this field. If the field is missing, the constructor will be called with a null argument, except for the Optional fields such as procedure. I will add a test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you added testJsonMissingFields test. The question is what's the scenario we pass {} json to TrinoQueryProperties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether or not an empty array is serialized depends on the configuration of the ObjectMapper in JsonCodec right? If airlift decides to set .setSerializationInclusion(JsonInclude.Include.NON_DEFAULT) then these fields won't be included.
I will remove the check if that scenario can be ignored.
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableCallArgument.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableExpression.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableExpression.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaSingleBackend.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaSingleBackend.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaSingleBackend.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaSingleBackend.java
Outdated
Show resolved
Hide resolved
33103ec to
714f415
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableCallArgument.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableExpression.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableCallArgument.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableCallArgument.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableCallArgument.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableCallArgument.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableExpression.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableExpression.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/SerializableExpression.java
Outdated
Show resolved
Hide resolved
5043e6c to
3b54ac9
Compare
|
Can we get this in now @ebyhr and @willmostly so we can ideally cut 12? |
|
@mosabua No, the review hasn't yet completed. |
ebyhr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I strongly disagree with the current approach because we have to fight with serialization issues of procedure arguments. The maintainability seems so bad.
Please consider different approach. For instance, a) adding Optional<String> queryId to TrinoQueryProperties and setting the value during parse. b) extracting a helper method which retrieves query id from kill_query procedure without relying on TrinoQueryProperties.
I remember you mentioned that TrinoQueryProperties class is used because some other information might be helpful in the future. This is assumption, not required for now. I don't think we want to handle in this PR.
98b634d to
893dcaf
Compare
I agree, having access to the procedure and arguments for routing was not worth it. I took the approach of extracting the queryId from |
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestTrinoQueryProperties.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Show resolved
Hide resolved
893dcaf to
ae59adc
Compare
Co-authored-by: Yuya Ebihara <[email protected]>
…inoQueryProperties
ae59adc to
b274916
Compare
| } | ||
| else { | ||
| queryId = tokens[1]; | ||
| return Optional.of(tokens[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Trino Gateway attempts to extract the query id from the body of queries using the runtime.kill_query procedure from the system catalog. This adds a test for this functionality.
Additional context and related issues
Release notes
( x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: